package com.kuiandjie.service;

import com.kuiandjie.dao.MessageDao;
import com.kuiandjie.entity.Log;
import com.kuiandjie.entity.Message;
import com.kuiandjie.util.DateUtil;

public class SendMsgService {
	MessageDao dao = new MessageDao();
	
	public Log addMessage(int employeeId, int projectId, String content, String name, String pic) {
		Message msg = new Message();
		msg.setContent(content);
		msg.setCreateTime(DateUtil.getNow());
		msg.setEmployeeId(employeeId);
		msg.setProjectId(projectId);
		int id = dao.addMsg(msg);
		Log log = null;
		if(id != -1) {
			log = new Log();
			log.setDesc(content);
			log.setEmployeeId(employeeId);
			log.setProjectId(projectId);
			log.setName(name);
			log.setTime(msg.getCreateTime());
			log.setPic(pic);
		}
		
		return log;
	}
}
